<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Customer</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container" id="app">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>玩家实时钱包查询</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="table-search">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">选择区服:</label>
                            <div class="layui-input-inline">
                                <select name="gameArea" class="layui-select" >

                                    <option v-for="(item,index) in services" :value="item.server_id" :selected="index==0">{{item.name}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">玩家账号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">角色名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="roleName" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">角色ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="roleId" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">金额</label>
                            <div class="layui-inline">
                                <div class="layui-input-inline" style="width: 100px;">
                                    <input type="number" name="amountChangedBegin" setp="1" min="0" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline" style="width: 100px;">
                                    <input type="number" name="amountChangedEnd" step="1" min="1" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">流水号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="code" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">货币类型</label>
                            <div class="layui-input-inline">
                                <select name="moneyType">
                                    <option value="">请选择</option>
                                    <option value="1">华夏币</option>
                                    <option value="2">银元</option>
                                    <option value="3">元宝</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">操作类型</label>
                            <div class="layui-input-inline">
                                <div id="opTypes"></div>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">记录时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="createDateBegin" id="createTime0"
                                       placeholder="开始时间" autocomplete="off" class="layui-input" />
                                <input type="text" name="createDateEnd" id="createTime1"
                                       placeholder="截止时间" autocomplete="off" class="layui-input" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn">
                                <i class="layui-icon"></i>搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="export" auth="moneyChange:export">导出</button>
    </div>
</script>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script src="/xm-select-v1.2.4/xm-select.js"></script>
<script>
    var opTypes = getEnum('operType')
    new Vue({
        el: "#app",
        data: {
            services: JSON.parse(localStorage.getItem('services')),
        },
        mounted: function () {
            layui.use(['form', 'table','laydate'], function () {
                var $ = layui.jquery,
                    form = layui.form,
                    laydate = layui.laydate,
                    table = layui.table,
                    laydate=layui.laydate;
                laydate.render({
                    elem: '#createTime0',
                    value: getYmd(0)
                });
                laydate.render({
                    elem: '#createTime1',
                    value: getYmd(1)
                })
                var data = [];
                for(var k in opTypes){
                    var v = opTypes[k];
                    data.push({
                        name:v.name,
                        value:v.id,
                    })

                }

                xmSelect.render({
                    el: '#opTypes',
                    name:"opTypes",
                    language: 'zn',
                    data: data
                })

                table.render({
                    width:1662,
                    elem: '#currentTableId',
                    where:form.val('table-search'),
                    url: '/admin/moneyChange/paginate',
                    defaultToolbar: ['filter', 'print'],
                    toolbar: '#toolbarDemo',
                    cols: [[
                        {type: "checkbox", width: 50},
                        {field: 'logDate', title:'记录时间',width:180 },
                        {field: 'serverId', title:'服务器ID'},
                        {field: 'memberName', title:'游戏账号' },
                        {field: 'roleId', title:'角色ID'},
                        {field: 'nick', title:'角色名'},
                        {field: 'moneyTypeName', title:'货币类型' },
                        {field: 'amountBefore', title:'变化前'},
                        {field: 'amountChanged', title:'变动数'},
                        {field: 'amountAfter', title:'变化后'},
                        {field: 'sourceName', title:'起点' },
                        {field: 'targetName', title:'结点' },
                        {field: 'getOrLostName', title:'得失' },
                        {field: 'jylsh', title:'交易流水号',templet:function () {
                                return '功能待定';
                        }},
                        {field: 'opTypeName', title:'操作类型' }
                    ]],
                    limits: [10, 15, 20, 25, 50, 100],
                    limit: 15,
                    page: true,
                    skin: 'line'
                });

                // 监听搜索操作
                form.on('submit(data-search-btn)', function (data) {
                    //执行搜索重载
                    table.reload('currentTableId', {
                        page: {
                            curr: 1
                        }
                        , where:form.val('table-search'),
                    }, 'data');
                    return false;
                });

                table.on('toolbar(currentTableFilter)', function (obj) {
                    if(obj.event === 'export'){ //导出
                        var searchData = form.val('table-search');
                        searchData.page = 1;
                        searchData.limit = 9999999;
                        var layerIndex = layer.msg("请求中请耐心等待...",{icon:16,time:999999999});
                        $.get('/admin/moneyChange/export',searchData,function(res){
                            layer.close(layerIndex)
                            browserDownload("/" + res.data);
                        });
                    }
                });

            });
        }
    })

</script>
</body>
</html>